using System;
using System.Data;
using System.Data.SqlClient;


/// <summary>
/// Summary description for Resume Class
/// </summary>
public partial class RecruitVietnam
{
    #region Save Resume by Recruiter
    public bool SaveResumes(
    string recruiterID,  
    string resumeID, string jobPosition)
    {
        bool saveItem = false;
        errorMessage = "";
        try
        {
            SqlServerProvider sqlServerProvider
            = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText =
            "SPSaveResumes";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[3] { "@RecruiterID", 
            "@ResumeID", "@JobPosition" };
            sqlServerProvider.ValueCollection =
            new string[3] { recruiterID, 
            resumeID, jobPosition };
            saveItem = 
            (sqlServerProvider.ExecuteNonQuery() > 0);
            sqlServerProvider.CloseConnection();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return saveItem;
    }
    #endregion
    

   public int AddNewOrUpdateResume(
   string resumeID,
   string userID,
   string resumeTitle,
   string contactEmail,
   string objective,
   string skills,
   string experienceYear, 
   string highestQualification,  
   string currentCompany,
   string viewable, 
   string template,
   bool confidential)
    {
        errorMessage = "";
        int returnValue = -1;
        try
        {
            SqlServerProvider sqlServerProvider
                = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText = "SPJSResume";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[12] { "@ResumeID", 
            "@UserID", "@ResumeTitle", 
            "@ContactEmail", "@Objective", "@Skills",
            "@ExperienceYear", "@CurrentCompany", 
            "@Viewable", "@TemplateResume",
            "@Confidental","@HighestQualification"};
            sqlServerProvider.ValueCollection =
            new string[12] { resumeID, userID, 
            resumeTitle, contactEmail, 
            objective, skills, experienceYear, 
            currentCompany, viewable, 
            template, ((confidential)?"1":"0") ,
            highestQualification};
            sqlServerProvider.ExecuteNonQuery();
            sqlServerProvider.ReturnValueParameter = "@ReturnValue";
            returnValue = sqlServerProvider.ReturnValue;
            sqlServerProvider.CloseConnection();                      
        }         
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return returnValue;
    }
    
   public bool AddNewOrUpdateResume(
   bool flag,
   string resumeID,
   string jobPosition,
   string jobCategoryID,
   string jobIndustryID,
   string provinceID,
   string city,
   string salaryFrom,
   string salaryTo,
   string currency,
   bool salaryNegotive,
   bool relocate, 
   string workType,
   string experienceLevel,
   string available,
   string description)
    {
        errorMessage = "";
        bool save = false;
        try
        {
            SqlServerProvider sqlServerProvider
            = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText = 
            "SPJSResumeDetail";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[16] { "@Flag", 
            "@ResumeID", "@JobPosition", 
            "@JobCategoryID", "@JobIndustryID", 
            "@ProvinceID", "@City", 
            "@SalaryFrom", "@SalaryTo",
            "@Currency", "@SalaryNegotive", 
            "@Relocate", "@WorkType", 
             "@ExperienceLevel",  "@Available", 
             "@Description"};
            sqlServerProvider.ValueCollection =
            new string[16] { ((flag)?"0":"1"), 
            resumeID, jobPosition, jobCategoryID,
            jobIndustryID, provinceID, 
            city, salaryFrom, salaryTo,
            currency, ((salaryNegotive)?"0":"1"), 
            ((relocate)?"0":"1"),
            workType, experienceLevel, 
            available, description};
            sqlServerProvider.ExecuteNonQuery();           
            sqlServerProvider.CloseConnection();
            save = true;             
        }         
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return save;
    }
    
   

   public bool ChooseActivateResume(   
   string resumeID,
   string userID)
    {
        errorMessage = "";
        bool save = false;
        try
        {
            SqlServerProvider sqlServerProvider
                = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText =
            "SPJSChooseResume";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[2] { "@UserID", "@ResumeID"};
            sqlServerProvider.ValueCollection =
            new string[2] { userID, resumeID};
            sqlServerProvider.ExecuteNonQuery();
            sqlServerProvider.CloseConnection();
            save = true;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return save;
    }
    
    public bool ActivateResume(
    string resumeID,
    string userID,
    string activate)
    {
        errorMessage = "";
        bool save = false;
        try
        {
            SqlServerProvider sqlServerProvider
                = new SqlServerProvider(connectionString);
            sqlServerProvider.CommandText =
            "SPJSActivateResume";
            sqlServerProvider.CommandType =
            CommandType.StoredProcedure;
            sqlServerProvider.ParameterCollection =
            new string[3] { "@UserID", "@ResumeID", "@Activate" };
            sqlServerProvider.ValueCollection =
            new string[3] { userID, resumeID, activate };
            sqlServerProvider.ExecuteNonQuery();
            sqlServerProvider.CloseConnection();
            save = true;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return save;
    }
}
